from django.db import models



class Message(models.Model):
    send = models.ForeignKey(to='auth.User',on_delete=models.CASCADE,db_comment='发送者',related_name='send_user')

    recv = models.ForeignKey(to='auth.User',on_delete=models.CASCADE,db_comment='接收者')

    text = models.TextField(db_comment='消息')

    created_time = models.DateTimeField(auto_now_add=True,db_comment='发送时间')

    class Meta:
        db_table = 'tb_message'

class UserInfo(models.Model):
    """
    头像、 出生日期、 昵称、姓名、性别、  所属用户（关系属性）
    """
    avatar = models.ImageField(upload_to='avatar',default='avatar/default.png',db_comment="用户头像",verbose_name="头像")

    birthday = models.DateField(null=True, blank=True, verbose_name="出生日期",db_comment="出生日期")

    nickname = models.CharField(max_length=120,verbose_name="昵称",db_comment="昵称",null=True, blank=True)

    name = models.CharField(max_length=120,verbose_name="姓名",db_comment="姓名",null=True, blank=True)

    gender = models.CharField(max_length=120,choices=(('m', '男'),('f', '女'),('s', '保密')),
                              verbose_name="性别",db_comment="性别",null=True,blank=True)

    user = models.OneToOneField(to='auth.User',on_delete=models.CASCADE,
                                    db_comment="所属用户",verbose_name='所属用户',
                                    related_name='info',
                                    null=True,blank=True)
    class Meta:
        db_table = 'tb_user_info'

